# coding:utf-8
# 特征点检测
import time
import cv2
img=cv2.imread('timg.jpg')
# print('图像的shape为：{}0'.format(img.shape))
# grayimg=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
# cv2.imshow('grayimg.png',grayimg)
# 使用sift来检测特征点
starttime=time.time()
sift=cv2.xfeatures2d.SIFT_create()
points=sift.detect(img,None)
cv2.drawKeypoints(img,points,img,(0,255,255),flags=cv2.DrawMatchesFlags_DEFAULT)
endtime=time.time()
print('运行的时间是{}'.format(endtime-starttime))
cv2.imshow('pic_poins',img)
cv2.waitKey (0)
cv2.destroyAllWindows()
print('SIFT关键点的数目为：{}'.format(len(points)))